package org.stormphoenix.bbsfamily

import com.github.dozermapper.core.Mapper
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit4.SpringRunner
import org.stormphoenix.bbsfamily.dao.UserMapper
import org.stormphoenix.bbsfamily.entity.UserDO
import org.stormphoenix.bbsfamily.entity.dto.UserDTO

@RunWith(SpringRunner::class)
@SpringBootTest
internal class DozerTest {
    @Autowired
    lateinit var userMapper: UserMapper

    @Autowired
    @Qualifier("dozerMapper")
    lateinit var mapper: Mapper

    @Test
    fun mappingUser() {
        var user: UserDO? = userMapper.findUserByUsername("wangcheng")
        Assert.assertNotNull(user)

        var userDto: UserDTO? = mapper.map(user, UserDTO::class.java)
        Assert.assertNotNull(userDto)
    }
}